home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / communic / pcmail / main / ndir.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  1.5 KB  |  119 lines

  1. /* This source was taken from the rn program by Larry Wall */
  2.  
  3.  
  4.  
  5. #ifdef    MSDOS
  6.  
  7. # include <sys/types.h>
  8.  
  9. # include "msd_dir.h"
  10.  
  11. #else
  12.  
  13. # ifdef LIBNDIR
  14.  
  15. #   include <ndir.h>
  16.  
  17. # else
  18.  
  19. #   ifndef USENDIR
  20.  
  21. #    include <sys/types.h>
  22.  
  23. #    include <sys/dir.h>
  24.  
  25. #   else
  26.  
  27.  
  28.  
  29. #ifndef DEV_BSIZE
  30.  
  31. #define    DEV_BSIZE    512
  32.  
  33. #endif
  34.  
  35. #define DIRBLKSIZ    DEV_BSIZE
  36.  
  37. #define    MAXNAMLEN    255
  38.  
  39.  
  40.  
  41. struct    direct {
  42.  
  43.     long    d_ino;            /* inode number of entry */
  44.  
  45.     short    d_reclen;        /* length of this record */
  46.  
  47.     short    d_namlen;        /* length of string in d_name */
  48.  
  49.     char    d_name[MAXNAMLEN + 1];    /* name must be no longer than this */
  50.  
  51. };
  52.  
  53.  
  54.  
  55. /*
  56.  
  57.  * The DIRSIZ macro gives the minimum record length which will hold
  58.  
  59.  * the directory entry.  This requires the amount of space in struct direct
  60.  
  61.  * without the d_name field, plus enough space for the name with a terminating
  62.  
  63.  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  64.  
  65.  */
  66.  
  67. #undef DIRSIZ
  68.  
  69. #define DIRSIZ(dp) \
  70.  
  71.     ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
  72.  
  73.  
  74.  
  75. /*
  76.  
  77.  * Definitions for library routines operating on directories.
  78.  
  79.  */
  80.  
  81. typedef struct _dirdesc {
  82.  
  83.     int    dd_fd;
  84.  
  85.     long    dd_loc;
  86.  
  87.     long    dd_size;
  88.  
  89.     char    dd_buf[DIRBLKSIZ];
  90.  
  91. } DIR;
  92.  
  93. #ifndef NULL
  94.  
  95. #define NULL 0
  96.  
  97. #endif
  98.  
  99. extern    DIR *opendir();
  100.  
  101. extern    struct direct *readdir();
  102.  
  103. extern    long telldir();
  104.  
  105. extern    void seekdir();
  106.  
  107. #define rewinddir(dirp)    seekdir((dirp), (long)0)
  108.  
  109. extern    void closedir();
  110.  
  111.  
  112.  
  113. #   endif
  114.  
  115. # endif
  116.  
  117. #endif
  118.  
  119.